package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.other._setOnClickListener
import com.cysion.study.R
import com.cysion.study.entity.ManagesEntity
import kotlinx.android.synthetic.main.item_private_manage.view.*

class PrivateManageAdapter(mEntities: MutableList<ManagesEntity>, mContext: Context) :
    BaseAdapter<ManagesEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val preview = 2000
        const val edit = 2001
        const val del = 2003
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ManagesEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_private_manage, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<ManagesEntity>(itemView) {
        override fun fillData(obj: ManagesEntity, position: Int) {
            itemView?.apply {
                //                itemView.tv_data.text=
                tv_title.text=obj.province+obj.city+obj.county
                tv_tag1.text="资格证："+obj.seniority+" ,"+obj.levelName//
                tv_content.text=obj.content
                tv_tag2.text="【"+obj.oneCategoryName+"】  "+"【"+obj.twoCategoryName+"】"
                tv_price.text=obj.money+"/"+obj.units
                tv_priview._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, preview)
                }
                tv_edit._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, edit)
                }
                tv_del._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, del)
                }
            }
        }

    }
}